<br />
<form id="cadastroResponsavel">
    <p><b>Dados do Respons&aacute;vel</b></p>
    <table  width="740">
<tr>
            <td width="70" align="right">Nome:</td>
<td colspan="3" align="left">
<input type="text" size="50" id="nomeResponsavel"  />
                <span id="msg_rnome" style="color: #cd0a0a; display: none">&nbsp; Preencha o campo nome.</span>            </td>
      <td width="70" align="right">CPF:</td>
<td width="276" align="left">
<input type="text" size="15" id="cpfResponsavel" onkeypress="mascara(this,cpf)" maxlength="14"   />
                <span id="msg_rcpf" style="color: #cd0a0a; display: none">&nbsp; Preencha o campo CPF.</span>            </td>
      </tr>
        <tr>
            <td align="right">Identidade:</td>
            <td width="126" align="left"><input type="text" size="20" maxlength="15" id="idtResponsavel"  />
              <span id="msg_rexpidt" style="color: #cd0a0a; display: none">&nbsp; Informe o &Oacute;rg&atilde;o Expedidor da identidade.</span>            </td>
          <td width="69" align="left"><div align="right"><span id="msg_ridt" style="color: #cd0a0a; display: none">&nbsp; Preencha o campo Identidade.</span> &Oacute;rgao Expedidor:</div></td>
          <td width="101" align="left"><div align="left">
            <input type="text" size="15" id="idtExpResponsavel"  />
          </div></td>
            <td align="right">Parentesco:<span id="msg_rparentesco" style="color: #cd0a0a; display: none">&nbsp; Selecione o parentesco.</span></td>
            <td align="left">
                <select id="parentesco"  >
                  <?php $this->load->view('parentesco/cbo_parentesco'); ?>
              </select>            </td>            
        </tr>
        <tr>
            <td align="right">E-Mail:</td>
            <td colspan="3" align="left"><input type="text" size="40" id="emailResp"  /></td>

            <td align="right">Profiss&atilde;o:<span id="msg_rprofissao" style="color: #cd0a0a; display: none">&nbsp; Selecione uma profiss&atilde;o.</span></td>
            <td align="left">
                <select id="profissao"  >
                  <option value=''></option>
                  <option value='1'>Arquiteto</option>
                  <option value='2'>Engenheiro Florestal</option>
                  <option value='3'>Funcion&aacute;rio P&uacute;blico</option>
        </select>        </tr>
       
        <tr>
            <td colspan="6" align="left">Respons&aacute;vel Financeiro:
                <input type="checkbox" id="responsavelDireto" value="1"  />            </td>
        </tr>
    </table>
<br /><br />
    <p><b>Endere&ccedil;o</b></p>
    <table width="740">       
  <tr>
            <td width="75" align="right">CEP:</td>
      <td width="151" align="left"><input type="text"  id="cepResp" size="9" maxlength="8" /></td>
      <td width="97" align="right">Endere&ccedil;o:</td>
      <td width="397" align="left"><input type="text"  id="logradouroResp" size="42" maxlength="42" /></td>
      </tr>
        <tr>
            <td colspan="2"><span id="msg_rcep" style="color: #cd0a0a; display: none">&nbsp; Informe o CEP.</span></td>
            <td colspan="2"><span id="msg_rlogradouro" style="color: #cd0a0a; display: none">&nbsp; Informe o endere&ccedil;o.</span></td></tr>
        <tr>            
            <td align="right">Bairro:</td>
            <td align="left"><input type="text"  id="bairroResp" size="20" maxlength="20" /></td>
            <td align="right">Complemento:</td>
            <td align="left"><input type="text"  id="complementoResp" size="42" maxlength="40" /></td>
        </tr>
        <tr><td colspan="4"><span id="msg_rbairro" style="color: #cd0a0a; display: none">&nbsp; Informe o bairro.</span></td></tr>
        <tr>
            <td align="right">Cidade/UF:
                <span id="msg_rcidade" style="color: #cd0a0a; display: none">&nbsp; Informe s cidade.</span>
                <span id="msg_ruf" style="color: #cd0a0a; display: none">&nbsp;Informe a campo uf.</span>            </td>
            <td align="left"><input type="text"  id="cidadeResp" size="25" maxlength="25" /></td>
            <td align="left">/
            <input type="text" size="2" maxlength="2" id="ufResp"  /></td>
            <td>Tipo do Endere&ccedil;o:
                <select id="tipoEnderecoResp"  >
                  <option value=''></option>
                  <option value='1'>Residencial</option>
                  <option value='2'>Comercial</option>
                  <option value='3'>Outro</option>
              </select>            </td>
        </tr>
    </table>
  <br /><br /><p><b>Telefones</b><span id="msg_rtelefone" style="color: #cd0a0a; display: none">&nbsp; Informe no m&iacute;nimo um telefone para contato.</span></p>
    <table width="740">
        
  <tr>
            <td align="right" width="16%">Residencial:</td>
            <td align="left" width="16%"><input type="text" size="15" maxlength="14" id="telResidencialResp" onkeypress="mascara(this,telefone)"   /></td>
            <td align="right" width="10%">Celular:</td>
      <td align="left" width="15%"><input type="text" size="15" maxlength="14" id="celularResp" onkeypress="mascara(this,telefone)"  /></td>
      <td align="right" width="13%">Trabalho:</td>
      <td width="30%" align="left"><input type="text" size="15" id="telefoneTrabalhoResp" maxlength="14" onkeypress="mascara(this,telefone)"  /></td>
      </tr>
    </table>
  <br /><br /><p><b>Dados Banc&aacute;rios</b></p>
    <table width="740">
            
  <tr>
            <td align="right" width="14%">Banco:</td>
<td colspan="5" align="left">
<select id="bancoResp"  >
                   <?php $this->load->view('banco/cbo_banco'); ?>
              </select></td>
      </tr>
      <tr>
      	<td align="right" width="14%">Conta Corrente:</td>
      <td align="left" width="14%"><input type="text" size="13" id="contaResp"  /></td>
      <td align="right" width="8%">Ag&ecirc;ncia:</td>
      <td width="12%" align="left"><input type="text" size="13" id="agenciaResp"  /></td>
            <td align="right" width="14%">D&eacute;bito Autom&aacute;tico:</td>
<td width="13%" align="left">
<select id="debitoAutomatico"   >
                  <option value=''></option>
                  <option value='1'>Sim</option>
                  <option value='0'>N&atilde;o</option>
              </select>            </td>
      </tr>
    </table>
<br />
    <input type="hidden" id="alunoId" value="<?php echo @$alunoId; ?>" />
    <p align="center"><input type="button" onclick="gravarDadosResponsavel()" id="btnCadastrarResponsavel" value="Cadastrar"></p>
</form>
<script>
$(document).ready(
        function(){

           $('#cepResp').change(function(){

                jQuery.ajax( {
                    type: "POST",
                    url: '?c=c_responsavel&m=buscaEnderecoResponsavel',
                    cache: false,
                    data: {cep:jQuery('input[id="cepResp"]').val()},
					
                    beforeSend: function (){
                            jQuery('#btnCadastrarResponsavel').attr("disabled",true);
                            jQuery('#cadastroResponsavel').addClass("div_carregando");
                            jQuery('#logradouroResp').attr('readonly', true);
                            jQuery('#bairroResp').attr('readonly', true);
                            jQuery('#cidadeResp').attr('readonly', true);
                            jQuery('#ufResp').attr('readonly', true);
                    },
                    complete:  function(){
                           jQuery('#cadastroResponsavel').removeClass("div_carregando");
                           jQuery('#btnCadastrarResponsavel').attr("disabled",false);
                        },
                    success: function(data){
                        
                        var dados = data.split('@');
                       
                        if(dados[0] == 1){
						
                            jQuery('#logradouroResp').attr('value', dados[1]);
                            jQuery('#bairroResp').attr('value', dados[2]);
                            jQuery('#cidadeResp').attr('value', dados[3]);
                            jQuery('#ufResp').attr('value', dados[4]);

                        } else if(dados[0] == 2){
						
                            jQuery('#cidadeResp').attr('value', dados[1]);
                            jQuery('#ufResp').attr('value', dados[2]);
							
                        } else {
						
                                jQuery('#logradouroResp').attr('readonly', false);
                                jQuery('#bairroResp').attr('readonly', false);
                                jQuery('#cidadeResp').attr('readonly', false);
                                jQuery('#ufResp').attr('readonly', false);

                        }
                        
                    }
                });

            });
        });
</script>
